package com.qyhl.webtv.module_live.teletext.newlivelist.item;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.entity.live.LiveRoomBean;
import com.qyhl.webtv.module_live.R;
import com.zhy.adapter.recyclerview.base.ItemViewDelegate;
import com.zhy.adapter.recyclerview.base.ViewHolder;

public class OmnimediaItemView implements ItemViewDelegate<LiveRoomBean> {
    private Context context;

    public OmnimediaItemView(Context context) {
        this.context = context;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.live_item_teletext_list;
    }

    @Override
    public boolean isForViewType(LiveRoomBean liveRoomBean, int i) {
        return liveRoomBean.getLivetype().equals("liveNews");

    }

    @Override
    public void convert(ViewHolder viewHolder, LiveRoomBean liveRoomBean, int i) {
        viewHolder.setText(R.id.item_live_title, liveRoomBean.getTitle());
        String hitCount = liveRoomBean.getHitcount();
        if (!StringUtils.isEmpty(hitCount)) {
            viewHolder.setText(R.id.item_live_friends, hitCount + "人参与");
        } else {
            viewHolder.setText(R.id.item_live_friends, "0人参与");
        }

        ImageView bg = viewHolder.getView(R.id.item_live_logo);
        viewHolder.setVisible(R.id.item_live_tagtype, false);

        ImageView review = viewHolder.getView(R.id.live_status);
        Glide.with(context)
                .load(liveRoomBean.getLogo())
                .apply(new RequestOptions().error(R.drawable.cover_large_default))
                .into(bg);
        //状态
        int status = Integer.parseInt(liveRoomBean.getStatus());
        switch (status) {
            case 6:
                //预告
                review.setVisibility(View.VISIBLE);
                review.setImageResource(R.drawable.icon_lives_forecast);
                break;
            case 7:
                //回放
                review.setVisibility(View.VISIBLE);
                review.setImageResource(R.drawable.icon_lives_review);
                break;
            case 2:
                //直播中
                review.setVisibility(View.VISIBLE);
                review.setImageResource(R.drawable.icon_lives_live);
                break;
            case 3:
                //结束
                review.setVisibility(View.VISIBLE);
                review.setImageResource(R.drawable.icon_lives_end);
                break;
            default:
                break;
        }
    }
}
